home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 607 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: EU.net!sun4nl!xs4all!marketgraph!rvg
  2. From: rvg@marketgraph.xs4all.nl (Ruud van Gaal)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: C Code prob
  5. Message-ID: <2232lai60.alamito@marketgraph.xs4all.nl>
  6. Date: Tue, 9 Jan 96 11:50:34 CET
  7. References: <Pine.SOL.3.91-941213.960108214431.23338A-100000@altair.dur.ac.uk>
  8. Reply-To: rvg@marketgraph.xs4all.nl
  9. X-Newsreader: Alamito Mail and News Manager (V2.0.4 for Waffle) registered to MARKETGRAPH VISUAL AUTOMATION
  10.  
  11. In <Pine.SOL.3.91-941213.960108214431.23338A-100000@altair.dur.ac.uk> Nick 
  12. Pratt <N.B.Pratt@durham.ac.uk> wrote:
  13.  
  14. >Im trying to code a get around for a program originally coded in MS-DOS 
  15. >Turbo C using cprint(). Im tryint to port this prog to my Amiga using the 
  16. >curses.lib. However, curses.lib does not print \r control codes, so I 
  17. >tried the following:
  18. >void cprintf(const char *fmt, ... )
  19. >{    char c, newfmt[4096];
  20. >    int i=0, j=0, len;
  21. >    va_list ap;
  22. >    va_start(ap,fmt);
  23. >    len = strlen(fmt);
  24. >    while( len > (j-1) )
  25. >    {
  26. >        c = fmt[j++];
  27. >        if( c == '\r' ) /* Discard any \r's */
  28. >            continue;
  29. >        newfmt[i++] = c; /* Otherwise, copy the char to the new array 
  30. */
  31. >    }
  32. >    /* printw() is out of curses.lib, and doesnt convert \r */
  33. >    printw(newfmt, ?????? );
  34. >    /* What I now need to do is call printw() with the format string of
  35. >       newfmt, and also with all the arguments supplied to cprintf();
  36. >       Whats the best way to do this?
  37. >     */
  38.  
  39. If possible, you could declare a local buffer (char buf[100] or some size), 
  40. and use vsprintf() to format the string inside cprint() and then pass the 
  41. converted string to printw().
  42.  
  43. >    va_end(ap);
  44. >    return;
  45. >}
  46.  
  47. --
  48. Ruud van Gaal
  49. MarketGraph Visual Automation
  50. E-Mail: rvg@marketgraph.xs4all.nl
  51. "...Works fascinates me. I could sit and watch it for hours..."
  52.  
  53.